﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Raona.Code.Model
{
    [Serializable]
    public class Method
    {
        public Method()
        {
            this.Parameters = new List<Parameter>();
        }
        public string Name { get; set; }
        public string OverloadedName { get; set; }
        public string ReturnType { get; set; }
        public List<Parameter> Parameters { get; set; }
        public string ParametersAsString
        {
            get
            {
                StringBuilder builder = new StringBuilder(string.Empty);
                for (int i = 0; i < this.Parameters.Count; i++)
                {
                    if (i == this.Parameters.Count - 1)
                        builder.AppendFormat("{0} {1}", this.Parameters[i].Type, this.Parameters[i].Name);
                    else
                        builder.AppendFormat("{0} {1}, ", this.Parameters[i].Type, this.Parameters[i].Name);
                }
                return builder.ToString();
            }
        }
        public string Arguments
        {
            get
            {
                StringBuilder builder = new StringBuilder(string.Empty);
                for (int i = 0; i < this.Parameters.Count; i++)
                {
                    if (i == this.Parameters.Count - 1)
                        builder.AppendFormat("{0}", this.Parameters[i].Name);
                    else
                        builder.AppendFormat("{0}, ", this.Parameters[i].Name);
                }
                return builder.ToString();
            }
        }
    }
}
